# config ssh
mkdir -p /zion0/etc/ssh

cat > /zion0/etc/ssh/ssh_config <<"EOF"
Host *
  StrictHostKeyChecking no
EOF


# run distccd

mkdir -p /zion0/var/log/distccd/
chmod 777 -R /zion0/var/log/distccd/
cat > /zion0/git_proj/run_distccd.sh <<"EOF"
set -eux
/usr/local/bin/distccd  --daemon --user distcc \
    --allow 172.16.2.0/24 --listen 0.0.0.0 \
    --nice 20 --jobs 80 \
    --verbose --log-level=debug --log-file=/zion0/var/log/distccd/distccd.log  

tail -f /dev/null

EOF

echo '' > /zion0/var/log/distccd/distccd.log  
chmod 777 /zion0/var/log/distccd/distccd.log  

# distccd 上 需要包含 源代码
docker rm -f distccd
docker run -d  \
    --name distccd \
    --restart always \
    --privileged=true \
    --network host \
    -v /zion0/etc/ssh/ssh_config:/etc/ssh/ssh_config:ro \
    -v /root/.ssh:/root/.ssh \
    -v /root/.config:/root/.config \
    -v /zion0/git_proj:/zion0/git_proj \
    -v /zion0/var/log/ccache:/zion0/var/log/ccache \
    -v /zion0/var/log/distccd:/zion0/var/log/distccd \
    -v /zion0/ccache_dir:/zion0/ccache_dir \
    openeuler/openeuler:22.03-lts-sp2-llvm-ccache-distcc \
     bash /zion0/git_proj/run_distccd.sh


tail -f /zion0/var/log/distccd/distccd.log  

#  && tail -f /dev/null
# docker run --rm  \
#     openeuler/openeuler:22.03-lts-sp2-llvm-ccache-distcc \
#     /opt/distcc/bin/distccd -h

# docker run -it --rm \
#     -v /zion0:/zion0 \
#      openeuler/openeuler:22.03-lts-sp2-llvm-ccache-distcc \
#      bash

# docker run -it --rm \
#     --network host \
#     -v /root/.ssh:/root/.ssh \
#     -v /root/.config:/root/.config \
#     -v /zion0/git_proj:/zion0/git_proj \
#     -v /zion0/var/log/ccache:/zion0/var/log/ccache \
#     -v /zion0/ccache_dir:/zion0/ccache_dir \
#     openeuler/openeuler:22.03-lts-sp2-llvm-ccache-distcc \
#     bash



# Please report bugs to distcc@lists.samba.org

# Usage:
#    distccd [OPTIONS]

# Options:
#     --help                     explain usage and exit
#     --version                  show version and exit
#     -P, --pid-file FILE        save daemon process id to file
#     -N, --nice LEVEL           lower priority, 20=most nice
#     --user USER                if run by root, change to this persona
#     --jobs, -j LIMIT           maximum tasks at any time
#     --job-lifetime SECONDS     maximum lifetime of a compile request
#   Networking:
#     -p, --port PORT            TCP port to listen on
#     --listen ADDRESS           IP address to listen on
#     -a, --allow IP[/BITS]      client address access control
#     --stats                    enable statistics reporting via HTTP server
#     --stats-port PORT          TCP port to listen on for statistics requests
#   Debug and trace:
#     --log-level=LEVEL          set detail level for log file
#       levels: critical, error, warning, notice, info, debug
#     --verbose                  set log level to "debug"
#     --no-detach                don't detach from parent (for daemontools, etc)
#     --log-file=FILE            send messages here instead of syslog
#     --log-stderr               send messages to stderr
#     --wizard                   for running under gdb
#   Mode of operation:
#     --inetd                    serve client connected to stdin
#     --daemon                   bind and listen on socket

# distccd runs either from inetd or as a standalone daemon to compile
# files submitted by the distcc client.

# distccd should only run on trusted networks.
